package org.casper.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.casper.bean.User;
import org.casper.util.DBUtil;

public class UserDao {

	public int addUser(User user){
		int resultCode = -1;
		Connection conn = null;
		PreparedStatement pstmt = null;
		conn = DBUtil.getConnection();
		try {
			pstmt = conn.prepareStatement("insert into t_user(username,userpass) values(?,?)");
			pstmt.setString(1, user.getUsername());
			pstmt.setString(2, user.getUserpass());
			resultCode = pstmt.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return resultCode;
	}
}
